<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用戶信息</title>
    <jsp:include page="includes/resources.jsp"/>
</head>
<body>
<div class="panel panel-info">
    <div class="panel-heading">
        <h3 class="panel-title">用戶信息列表</h3>
    </div>
    <div class="panel-body">
        <table class="table table-striped">
            <thead>
            <tr>
                <th>ID</th>
                <th>用户名</th>
                <th>性别</th>
                <th>创建时间</th>
            </tr>
            </thead>
            <tbody id="userInfo"></tbody>
        </table>
    </div>
</div>

<script id="userTemplate" type="text/x-jquery-tmpl">
    <tr>
        <td>{{= id}}</td>
        <td>{{= name}}</td>
        <td>{{= sex == 1 ? '男' : '女'}}</td>
        <td>{{= createTime}}</td>
    </tr>
</script>

<script>
    $(function(){
        $.get("${webroot}/user/list", function(ret){
            if(ret.code == 0){
                $("#userTemplate").tmpl(ret.data).appendTo('#userInfo');
            }else {
                alert(ret.msg);
            }
        });
    });
</script>
</body>
</html>
